require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsArenaBattleHandler ={};
local this = RedDotsArenaBattleHandler;

function RedDotsArenaBattleHandler.init()
    CloseEvent(Config.EventType.Fresh_Arena,this.update);
    ListenEvent(Config.EventType.Fresh_Arena,this.update);
    CloseEvent(Config.EventType.refreshDefFormation, this.update);
    ListenEvent(Config.EventType.refreshDefFormation, this.update);
    return this;
end


--参数 无
function RedDotsArenaBattleHandler.getFlag(...)
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.Arena,false) then
        local arenaBaseoInfo = logicMgr.ArenaManager.getBaseInfo();
        -- if arenaBaseoInfo.freeTimes > arenaBaseoInfo.times and (logicMgr.ArenaManager.getBaseInfo().endTime - Config.serverTime) > 0 then
        --     return Config.RedDotsFlagState.Needful;
        -- end
        if arenaBaseoInfo.endTime * 0.001 - HelperFunc.GetServerTime() > 0 and logicMgr.FormationManager.checkDefFormationRedDotByType(EnumConst.FormationType.ArenaDef) then
            return Config.RedDotsFlagState.Needful;
        end
    end
    return Config.RedDotsFlagState.None;
end


function RedDotsArenaBattleHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.ArenaBattle);
end